@echo off

for /F "tokens=2* delims= " %%A in ('reg query "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion" /v ProductName') do (
    set OS_Name=%%B
)

if /i "%OS_Name:~0,10%"=="Windows XP" (
    echo Windows XP
) else if /i "%OS_Name:~0,9%"=="Windows 7" (
    echo Windows 7
) else if /i "%OS_Name:~0,9%"=="Windows 8" (
    echo Windows 8
) else if /i "%OS_Name:~0,10%"=="Windows 10" (
    echo Windows 10
) else if /i "%OS_Name:~0,10%"=="Windows 11" (
    echo Windows 11
)

echo.
pause